{{--<div class="bjui-pageHeader" style="background-color:#fefefe; border-bottom:none;">
    <form data-toggle="ajaxform" action="/admin/order-type/process-add">
        <input type="hidden" name="orderTypeId" value="{{$orderTypeId}}">
        <fieldset>
            <legend style="font-weight:normal;">添加步骤：</legend>
            <div  class="row-input" style="margin:0; padding:1px 5px 5px;">
                @foreach ($processList as $v)
                    <input type="checkbox" name="process[]" id="process_checkbox{{$v->id}}" value="{{$v->id}}" data-toggle="icheck" data-label="{{$v->title}}">
                @endforeach

                <div class="btn-group">
                    <button type="submit" class="btn-green" data-icon="search">添加</button>
                    <button type="reset" class="btn-orange" data-icon="times">重置</button>
                </div>
            </div>
        </fieldset>
    </form>
</div>--}}
<div class="bjui-pageContent">
    <button type="button" class="btn-green" data-toggle="dialog" data-options="{
            id:'order-type-process-add-dialog',
            url:'/admin/order-type/process-add',
            data:{orderTypeId:{{$orderTypeId}}},
            width:800,
            height:500,
            title:'添加'
        }">
        添加
    </button>
    <table class="table table-bordered" data-toggle="datagrid" data-options="{
        height: '100%',
        gridTitle : '工序管理',
        showToolbar: false,
        toolbarItem: 'add',
        editMode: 'inline',
        local: 'local',
        dataUrl: '/admin/order-type/process-list',
        postData:{'orderTypeId':{{$orderTypeId}} },
        editUrl: '/admin/order-type/process-edit',
        delUrl: '/admin/order-type/process-del',
        delPK: 'id',
        linenumberAll: true,
        sortAll: false,
        contextMenuH: true,
        contextMenuB: true,
        inlineEditMult: false,
        paging: {showPagenum:10, selectPageSize:'20,50,100', pageCurrent:1, pageSize:20},
        showEditbtnscol: '操作',
        customEditbtns: {width:200,position:'replace'},
        fullGrid: true,
        fieldSortable: false,
        filterThead: false,
        columnMenu: false,
        }">
        <thead>
        <tr>
            <th data-options="{name:'title',align:'center',width:100,edit:false}">工序名称</th>
            <th data-options="{name:'step_number',align:'center',width:100}">序号</th>
            <th data-options="{ render:'process_next_step', align:'center',width:100}">下一步骤</th>
            <th data-options="{ name:'meanwhile_next_step', type:'select', items:'is_meanwhile_next_step', align:'center',width:100}">下一步可同时开工</th>
            <th data-options="{ render:'set_process_waste', align:'center',width:100}">工序废品</th>
            <th data-options="{ render:'set_process_product', align:'center',width:100}">工序半成品</th>
            <th data-options="{ render:'set_process_next_step', align:'center',width:100}">选择下一步骤</th>
            {{--<th data-options="{name:'actionStrs',align:'center',width:100, edit:false}">动作</th>--}}
            <th data-options="{ name:'actionArr', edit:false, render:'set_action_permission', align:'center',width:100}">动作权限</th>
            <th data-options="{ render:'set_process_action', align:'center',width:100}">设置动作</th>
            {{--<th data-options="{ name:'id', render:'set_handling_permission', align:'center',width:100}">权限</th>--}}
            {{--<th data-options="{name:'jurisdictionStrs',align:'center',width:100, edit:false}">权限</th>--}}
            {{--<th data-options="{ render:'set_process_jurisdiction', align:'center',width:100}">设置权限</th>--}}
            {{--<th data-options="{name:'is_over',type:'select',items:[{0:'否',1:'是'}],align:'center',width:100}">是否结束</th>--}}
        </tr>
        </thead>
    </table>
</div>
<script>
    function process_next_step(value, data){
        if(data.nextSteps){
            if(data.nextSteps.length){
                html = '';
                $(data.nextSteps).each(function(index,e){
                    html += e.step_number + ',';
                })
            }else{
                html = '结束';
            }
            return html
        }else{
            return
        }
    }
    function set_process_product(value, data){
        html = '<button type="button" class="btn btn-green" data-toggle="navtab" data-options="{id:\'set-process-product-navtab\',fresh:true, url:\'/admin/order-type/set-process-product\', title:\'工序半成品设置\',width:500,height:500, data:{id:' + data.id + ',orderTypeId:{{$orderTypeId}}}}"><i class="fa fa-edit"></i> 设置</button>';
        return html;
    }

    function set_process_waste(value, data){
        html = '<button type="button" class="btn btn-green" data-toggle="navtab" data-options="{id:\'set-process-waste-navtab\',fresh:true, url:\'/admin/order-type/set-process-waste\', title:\'工序废品设置\',width:500,height:500, data:{id:' + data.id + ',orderTypeId:{{$orderTypeId}}}}"><i class="fa fa-edit"></i> 设置</button>';
        return html;
    }

    function set_process_next_step(value, data){
        html = '<button type="button" class="btn btn-green" data-toggle="dialog" data-options="{id:\'set-ordertype-prosess-step-dialog\',fresh:true, url:\'/admin/order-type/set-next-process\', title:\'选择下一步骤\',width:500,height:500, data:{id:' + data.id + ',orderTypeId:{{$orderTypeId}}}}"><i class="fa fa-edit"></i> 设置</button>';
        return html;
    }

    function set_process_action(value, data){
        html = '<button type="button" class="btn btn-green" data-toggle="dialog" data-options="{id:\'set-ordertype-prosess-step-dialog\',fresh:true, url:\'/admin/order-type/set-process-action\', title:\'设置步骤\',width:500,height:500, data:{id:' + data.id + ',orderTypeId:{{$orderTypeId}}}}"><i class="fa fa-edit"></i> 设置</button>';
        return html;
    }

    function set_process_jurisdiction(value, data){
        html = '<button type="button" class="btn btn-green" data-toggle="dialog" data-options="{id:\'set-ordertype-prosess-jurisdiction\',fresh:true, url:\'/admin/program/set-jurisdiction\', title:\'设置权限\',width:800,height:600, data:{id:' + data.id + ',orderTypeId:{{$orderTypeId}}}}"><i class="fa fa-edit"></i> 设置</button>';
        return html;
    }

    function set_handling_permission(value, data){
        type_id = 2;
        html = set_permission(value, type_id, 1, '经办');
        html += set_permission(value, type_id, 2, '分配');
        return html;
    }

    function set_action_permission(value, data){
        node_id = data.id;
        type_id = 1;
        var html = '';
        $(value).each(function(index,e){
            html += set_permission(node_id, type_id, e.id, e.title);
        })
        return html;
    }

    function set_permission(node_id, type_id, type_action, title){

        html = '<button type="button" class="btn btn-green" data-toggle="dialog" data-options="{id:\'set-permission-dialog-'+type_action+'\',fresh:true, url:\'/admin/permission/list\', title:\'设置'+title+'权限\',width:700,height:500, data:{type_id:' + type_id + ',node_id:'+node_id+',type_action:'+type_action+'}}"><i class="fa fa-edit"></i> '+ title +'</button>';

        return html;
    }

    function is_meanwhile_next_step() {
        return [{'yes':'是'}, {'no':'否'}]
    }



</script>